Skip to content

Rename test functions to follow repository conventions#228

Merged
josecelano merged 13 commits intomainfrom
227-rename-test-functions-to-follow-conventions
Dec 12, 2025
Merged

Rename test functions to follow repository conventions#228
josecelano merged 13 commits intomainfrom
227-rename-test-functions-to-follow-conventions

Conversation

@josecelano
Copy link
Copy Markdown
Member

Overview

This PR systematically renames all unit test functions and helper functions that use the test_ prefix to follow the repository's established naming convention using the it_should_ prefix with behavior-driven naming.

Changes

Test Functions Renamed

  • 93 test functions renamed from test_* to it_should_*_when_* or it_should_*_given_* pattern
  • 14 helper functions renamed from test_* to fixture_* or appropriate descriptive names

Files Modified (20 files)

Phase 0 - Core Application Layer:

  1. src/application/command_handlers/create/config/environment_config.rs (23 tests)
  2. src/application/command_handlers/create/config/errors.rs (10 tests)
  3. src/application/command_handlers/create/config/ssh_credentials_config.rs (9 tests)
  4. src/application/command_handlers/create/config/tracker/tracker_core_section.rs (4 tests)
  5. src/application/command_handlers/create/config/tracker/tracker_section.rs (5 tests)
  6. src/application/steps/application/create_tracker_storage.rs + init_tracker_database.rs (2 tests)

Phase 1 - Infrastructure Layer:
7. src/infrastructure/external_validators/running_services.rs (7 tests)
8. src/infrastructure/templating/docker_compose/template/renderer/env.rs (1 test)
9. src/infrastructure/templating/docker_compose/template/renderer/project_generator.rs (4 tests)
10. src/infrastructure/templating/tofu/template/common/renderer/project_generator.rs (3 helpers)

Phase 2 - Presentation Layer:
11. src/presentation/controllers/test/errors.rs (4 tests)
12. src/presentation/controllers/test/handler.rs (1 helper)
13. src/presentation/tests/reentrancy_fix_test.rs (2 tests)

Phase 3 - Testing Utilities:
14. src/testing/integration/ssh_server/mod.rs (2 trait methods)
15. src/testing/integration/ssh_server/real_container.rs (4 methods)
16. src/testing/integration/ssh_server/mock_container.rs (4 methods)
17. src/testing/e2e/containers/actions/ssh_wait.rs (1 helper)

Phase 4 - Integration Tests:
18. tests/template_integration.rs (4 tests)

Benefits

  • ✅ Clear behavior documentation in test names
  • ✅ Follows established repository conventions defined in docs/contributing/testing/unit-testing.md
  • ✅ Improves code discoverability and readability
  • ✅ Better adherence to BDD (Behavior-Driven Development) principles
  • ✅ Consistent naming across entire codebase

Testing

  • ✅ All 315 tests pass
  • ✅ All linters pass (markdown, yaml, toml, cspell, clippy, rustfmt, shellcheck)
  • ✅ Each file was tested individually after modification
  • ✅ Systematic approach with one commit per file/group

Related

Checklist

  • All test functions renamed to follow conventions
  • All helper functions renamed appropriately
  • All call sites updated
  • All tests pass
  • All linters pass
  • Refactor plan marked as completed
  • Each change committed with proper message

…entions

Renamed 23 test functions from test_* to it_should_*_when_* pattern to align
with repository conventions defined in docs/contributing/testing/unit-testing.md

Tests: All 23 tests pass
Linters: All linters pass
Renamed 10 test functions from test_* to it_should_*_when_* pattern.

Tests: All 10 tests pass
Linters: Pass
Renamed 9 test functions to follow conventions.

Tests: All 9 tests pass
Renamed 9 test functions (4 in tracker_core_section.rs, 5 in tracker_section.rs).

Tests: All tests pass
Renamed 2 test functions in create_tracker_storage.rs and init_tracker_database.rs.

Tests: All tests pass
Renamed 7 test functions.

Tests: All tests pass
Renamed 5 test functions in env.rs and project_generator.rs.

Tests: All tests pass
Renamed 3 helper functions from test_* to fixture_* prefix to clarify
they are test fixtures, not actual tests. Updated all call sites.

Tests: All tests pass
Renamed 6 test functions and 1 helper function in test controllers and reentrancy tests.

Tests: All tests pass
Renamed credential methods from test_username/test_password to username/password
and test_ssh_connection to verify_ssh_connection. Updated all call sites.

Tests: All tests pass
Renamed 4 integration test functions.

Tests: All tests pass
All test functions and helper functions have been renamed to follow conventions.
93 test functions and 14 helper functions renamed across 20 files.

All tests pass. All linters pass.
@josecelano josecelano self-assigned this Dec 12, 2025
@josecelano josecelano linked an issue Dec 12, 2025 that may be closed by this pull request
- Add rule #15 to Essential Rules section in AGENTS.md
- Emphasizes CRITICAL importance of using it_should_* pattern
- Explicitly forbids test_* prefix for test function names
- References docs/contributing/testing/unit-testing.md for details
- Includes examples of correct vs incorrect naming
- Preventive measure to avoid future test naming violations
@josecelano
Copy link
Copy Markdown
Member Author

ACK d4ed0ad

@josecelano josecelano merged commit 2709c28 into main Dec 12, 2025
34 checks passed
josecelano added a commit that referenced this pull request Dec 12, 2025
- Move entry from active-refactorings.md to completed-refactorings.md
- Add completion details (93 test functions, 14 helpers, 20 files, PR #228)
- Delete refactoring plan document (work now in git history)
- Clear active-refactorings.md table (no active refactorings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename test functions to follow repository conventions

1 participant